Technical Q&A HW71
Sample code for allocating an amount of dictionary space


Q: Do you have any sample code for allocating an amount of dictionary space and filling that amount with any value?

A: Yes, you can use the words allot, followed by erase or fill to accomplish allocating and initializing a section of dictionary memory. Here are some examples:

                     \ declare a variable called xyz and allocate 100 bytes for it
here .               \ notice the top dictionary address
variable xyz here .  \ now view the address of xyz
100 allot here .     \ notice the new dictionary top is 100 bytes higher
xyz 100 dump         \ dump the 100 byte area for xyz

Now, repeat the above code twice, once adding erase and once adding fill after allocating the dictionary memory. That is, first use allot, then erase or fill. Note the stack comment for erase is ( addr len -- ). fill has a stack comment which is ( addr len byte -- ).

[Oct 11 1999]


Developer Documentation | Technical Notes | Development Kits | Sample Code